---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Mandates/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 21:59:58

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Mandates";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Mandates

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Tuesday, May 26, 2015                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. *********************************;
. **      Peace to War            *;
. *********************************;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Mandates/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 
>                 diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1
>                 prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 prob_hat21 lo21 hi21
>                 diff_hat01 diff_lo01 diff_hi01 diff_hat11 diff_lo11 diff_hi11
>                 delta_hat delta_lo delta_hi delta_hat1 delta_lo1 delta_hi1 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3. *tl2 milservice tl2_mil tl1 tl1_mil;
.  scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_OneTerm=1;
  9. scalar h_TwoTerms=1;
 10. scalar h_Parliament = 0;
 11. scalar h_CivilWar = 0;
 12. scalar h_GDPpc =  12589.35;
 13. scalar h_Growth = 3.453132;
 14. scalar h_MajorPower = 0;
 15. scalar h_Borders = 2;
 16. scalar h_Mobilization =  -.0008714 ;
 17. scalar h_Time = 5;
 18.  scalar h_Rivalry = 0;
 19. scalar h_Female = 0;
 20. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Civilian
>     + MG_b3*(h_Accountable*h_Civilian)
>     + MG_b4*h_Accountable
>     + MG_b5*(h_Accountable*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 21.  generate x_betahat1 = MG_b1*h_OneTerm
>     + MG_b2*h_Civilian
>     + MG_b3*(h_OneTerm*h_Civilian)
>     + MG_b4*h_Accountable
>     + MG_b5*(h_Accountable*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 22.  generate x_betahat2 = MG_b1*h_Accountable
>     + MG_b2*h_Civilian
>     + MG_b3*(h_Accountable*h_Civilian)
>     + MG_b4*h_TwoTerms
>     + MG_b5*(h_TwoTerms*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 23.   gen prob0=1/(1+exp(-x_betahat0));
 24. gen prob1=1/(1+exp(-x_betahat1));
 25. gen prob2=1/(1+exp(-x_betahat2));
 26.  gen diff0=prob1-prob0 ;
 27. gen diff1=prob2-prob0 ;
 28. egen probhat0=mean(prob0) ;
 29. egen probhat1=mean(prob1) ;
 30. egen probhat2=mean(prob2) ;
 31. egen diffhat0=mean(diff0) ;
 32. egen diffhat1=mean(diff1) ;
 33. generate x_betahat01 =   MG_b1*h_Accountable
>     + MG_b2*h_Military
>     + MG_b3*(h_Accountable*h_Military)
>     + MG_b4*h_Accountable
>     + MG_b5*(h_Accountable*h_Military)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 34.  generate x_betahat11 =   MG_b1*h_OneTerm
>     + MG_b2*h_Military
>     + MG_b3*(h_OneTerm*h_Military)
>     + MG_b4*h_Accountable
>     + MG_b5*(h_Accountable*h_Military)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 35.   generate x_betahat21 =   MG_b1*h_Accountable
>     + MG_b2*h_Military
>     + MG_b3*(h_Accountable*h_Military)
>     + MG_b4*h_TwoTerms
>     + MG_b5*(h_TwoTerms*h_Military)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 36.   gen prob01=1/(1+exp(-x_betahat01));
 37. gen prob11=1/(1+exp(-x_betahat11));
 38. gen prob21=1/(1+exp(-x_betahat21));
 39. gen diff01=prob11-prob01 ;
 40. gen diff11=prob21-prob01 ;
 41. egen probhat01=mean(prob01) ;
 42. egen probhat11=mean(prob11) ;
 43. egen probhat21=mean(prob21) ;
 44. egen diffhat01=mean(diff01) ;
 45. egen diffhat11=mean(diff11) ;
 46. gen delta=diff01-diff0;
 47. gen delta1=diff11-diff1;
 48. egen deltahat=mean(delta);
 49. egen deltahat1=mean(delta1);
 50. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2
>          diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1
>          prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 prob_hat21 lo21 hi21
>          diff_hat01 diff_lo01 diff_hi01 diff_hat11 diff_lo11 diff_hi11
>          delta_hat delta_lo delta_hi  delta_hat1 delta_lo1 delta_hi1;
 51.     _pctile prob0, p(2.5,97.5) ;
 52.     scalar `lo0'=r(r1) ;
 53.     scalar `hi0'=r(r2) ;
 54.     _pctile prob1, p(2.5,97.5) ;
 55.     scalar `lo1'=r(r1) ;
 56.     scalar `hi1'=r(r2) ;
 57.     _pctile prob2, p(2.5,97.5) ;
 58.     scalar `lo2'=r(r1) ;
 59.     scalar `hi2'=r(r2) ;
 60.         _pctile diff0, p(2.5,97.5) ;
 61.     scalar `diff_lo0'= r(r1) ;
 62.     scalar `diff_hi0'=r(r2) ;
 63.     _pctile diff1, p(2.5,97.5) ;
 64.     scalar `diff_lo1'= r(r1) ;
 65.     scalar `diff_hi1'=r(r2) ;
 66.     scalar `prob_hat0'=probhat0 ;
 67.     scalar `prob_hat1'=probhat1 ;
 68.     scalar `prob_hat2'=probhat2 ;
 69.     scalar `diff_hat0'=diffhat0 ;
 70.     scalar `diff_hat1'=diffhat1 ;
 71.        _pctile prob01, p(2.5,97.5) ;
 72.     scalar `lo01'=r(r1) ;
 73.     scalar `hi01'=r(r2) ;
 74.     _pctile prob11, p(2.5,97.5) ;
 75.     scalar `lo11'=r(r1) ;
 76.     scalar `hi11'=r(r2) ;
 77.     _pctile prob21, p(2.5,97.5) ;
 78.     scalar `lo21'=r(r1) ;
 79.     scalar `hi21'=r(r2) ;
 80.     _pctile diff01, p(2.5,97.5) ;
 81.     scalar `diff_lo01'= r(r1) ;
 82.     scalar `diff_hi01'=r(r2) ;
 83.     _pctile diff11, p(2.5,97.5) ;
 84.     scalar `diff_lo11'= r(r1) ;
 85.     scalar `diff_hi11'=r(r2) ;
 86.     scalar `prob_hat01'=probhat01 ;
 87.     scalar `prob_hat11'=probhat11 ;
 88.     scalar `prob_hat21'=probhat21 ;
 89.     scalar `diff_hat01'=diffhat01 ;
 90.     scalar `diff_hat11'=diffhat11 ;
 91.     _pctile delta, p(2.5,97.5) ;
 92.     scalar `delta_lo'= r(r1) ;
 93.     scalar `delta_hi'=r(r2) ;
 94.     _pctile delta1, p(2.5,97.5) ;
 95.     scalar `delta_lo1'= r(r1) ;
 96.     scalar `delta_hi1'=r(r2) ;
 97.     scalar `delta_hat'=deltahat;
 98.     scalar `delta_hat1'=deltahat1;
 99.     post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`prob_hat2') (`lo2') (`hi2')
>                 (`diff_hat0') (`diff_lo0') (`diff_hi0') (`diff_hat1') (`diff_lo1') (`diff_hi1')
>                 (`prob_hat01') (`lo01') (`hi01') (`prob_hat11') (`lo11') (`hi11')  (`prob_hat21') (`lo21') (`hi21')
>                 (`diff_hat01') (`diff_lo01') (`diff_hi01') (`diff_hat11') (`diff_lo11') (`diff_hi11')
>                 (`delta_hat') (`delta_lo') (`delta_hi') (`delta_hat1') (`delta_lo1') (`delta_hi1')
> 
>     ;
100.     } ;
101.     drop    x_betahat0 x_betahat1 x_betahat2
>             prob0 prob1 prob2 
>             diff0 diff1
>             probhat0 probhat1 probhat2
>             diffhat0 diffhat1
>             x_betahat01 x_betahat11 x_betahat21
>             prob01 prob11 prob21
>             diff01 diff11
>             probhat01 probhat11 probhat21
>             diffhat01 diffhat11
>             delta deltahat delta1 deltahat1;
102.     local a=`a'+ .1 ;
103.     display "." _c ;
104.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .0532341           .   .0532341   .0532341
         lo0 |         1    .0359737           .   .0359737   .0359737
         hi0 |         1    .0748641           .   .0748641   .0748641
   prob_hat1 |         1    .0235337           .   .0235337   .0235337
         lo1 |         1    .0144135           .   .0144135   .0144135
-------------+--------------------------------------------------------
         hi1 |         1    .0363548           .   .0363548   .0363548
   prob_hat2 |         1    .0511206           .   .0511206   .0511206
         lo2 |         1    .0162607           .   .0162607   .0162607
         hi2 |         1    .1217459           .   .1217459   .1217459
   diff_hat0 |         1   -.0297004           .  -.0297004  -.0297004
-------------+--------------------------------------------------------
    diff_lo0 |         1   -.0500763           .  -.0500763  -.0500763
    diff_hi0 |         1    -.012281           .   -.012281   -.012281
   diff_hat1 |         1   -.0021135           .  -.0021135  -.0021135
    diff_lo1 |         1   -.0413878           .  -.0413878  -.0413878
    diff_hi1 |         1    .0665394           .   .0665394   .0665394
-------------+--------------------------------------------------------
  prob_hat01 |         1    .0744797           .   .0744797   .0744797
        lo01 |         1    .0496858           .   .0496858   .0496858
        hi01 |         1    .1071969           .   .1071969   .1071969
  prob_hat11 |         1    .0550144           .   .0550144   .0550144
        lo11 |         1    .0064291           .   .0064291   .0064291
-------------+--------------------------------------------------------
        hi11 |         1    .2020794           .   .2020794   .2020794
  prob_hat21 |         1    .0697285           .   .0697285   .0697285
        lo21 |         1    .0231676           .   .0231676   .0231676
        hi21 |         1    .1578432           .   .1578432   .1578432
  diff_hat01 |         1   -.0194653           .  -.0194653  -.0194653
-------------+--------------------------------------------------------
   diff_lo01 |         1   -.0797126           .  -.0797126  -.0797126
   diff_hi01 |         1     .123865           .    .123865    .123865
  diff_hat11 |         1   -.0047511           .  -.0047511  -.0047511
   diff_lo11 |         1   -.0585627           .  -.0585627  -.0585627
   diff_hi11 |         1    .0832597           .   .0832597   .0832597
-------------+--------------------------------------------------------
   delta_hat |         1    .0102351           .   .0102351   .0102351
    delta_lo |         1   -.0487314           .  -.0487314  -.0487314
    delta_hi |         1    .1547443           .   .1547443   .1547443
  delta_hat1 |         1   -.0026376           .  -.0026376  -.0026376
   delta_lo1 |         1   -.0877325           .  -.0877325  -.0877325
-------------+--------------------------------------------------------
   delta_hi1 |         1    .0903435           .   .0903435   .0903435

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Mandates/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 21:59:58
---------------------------------------------------------------------------------------------------------------------------
